<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
    request.setCharacterEncoding("UTF-8");
    String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/WEB-INF/JSP/backHome/modalWindows/StudentsListPageAsThree.jsp" %>
<%@ include file="/WEB-INF/JSP/backHome/modalWindows/CoachListPage.jsp" %>
<%@ include file="/WEB-INF/JSP/backHome/modalWindows/CoachesListPage.jsp" %>
<%@ include file="/WEB-INF/JSP/backHome/modalWindows/CartimeListPage.jsp" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=path%>/CSS/backLayout.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/CSS/bombBox.css">
</head>
<style>
    select {
        width: 234px;
        height: 31px
    }
    .tr{
        background-color: #57a0ff;
        font-weight:700;
    }

    .tr td {
        font-size: 14px;
        color: #ffffff
    }

    .tr_td {
        height: 40px;
    }

    .tr_td td {
        border-bottom: 1px solid #ededed;
        text-align: center;
    }

    tr td:nth-child(1) {
        font-size: 14px;
        color: #cccccc
    }

    .date {
        border: 0;
        background: #ffffff;
        text-align: center;
    }

    .tr_td td:nth-child(1) {
        border-left: 1px solid #cccccc;
    }

    .tr_td td:nth-child(3) {
        border-right: 1px solid #cccccc;
    }

    .addTable.deleteTable:HOVER {
        cursor: pointer;
    }

    type[type='checkbox'] {
        width: 15px
    }

    .botton input {
        width: 230px;
    }

    .div_zilei {
        height: 30px
    }
    .div_input_hang {
        width: 100%;
        height: 40px;
    }
    .input_hang {
        float: left;
        width: 500px;
        height: 40px;
    }
</style>
<body style="background: #f5f5f5">
<div class="main">
    <div id="modal-overlay">

    </div>
    <div class="weizhi">
        练车管理>>科目三分车>>新增
    </div>
    <div class="div_body" style="box-shadow: 0 0 5px #cccccc;">
        <%--提示的隐藏标识--%>
        <input type="hidden" id="alertType" value="${alertType}">
        <div class="div_form">
            <form action="<%=path%>/DrivingSys/add_shareCarThreeReg" id="update_shar" class="form"
                  onsubmit="StopRepeat()" method="get">
                <div class="div_input_hang">
                    <div class="input_hang">
                        <span class="gn_name">驾校&nbsp;:&nbsp;</span>
                        <input disabled='disabled' type="text" name="name" value="${department}" readonly="readonly"
                               style="color: gray;"/>
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">单据编号&nbsp;:&nbsp;</span>
                        <input type="text" name="fnumber" value="${fnumber}" style="color: gray;"
                               readonly="readonly"/>
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">业务日期&nbsp;:&nbsp;</span>
                        <input type="text" name="fbizdate" id="fbizdate_bind" value="${time}"
                               onclick="WdatePicker({el:'fbizdate_bind',dateFmt:'yyyy-MM-dd'})"/>
                        <img onclick="WdatePicker({el:'fbizdate_bind',dateFmt:'yyyy-MM-dd'})"
                             src="<%=path%>/image/date.jpg" align="absmiddle" style="padding-left: 15px">
                    </div>
                </div>
                <div class="div_input_hang">
                    <div class="input_hang">
                        <span class="gn_name">参考信息&nbsp;:&nbsp;</span>
                        <input name="fdescription"/>
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">单据状态&nbsp;:&nbsp;</span>
                        <select name="cfbillstate">
                            <option style="color: gray;" value="3">新增</option>
                        </select>
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">练车时间&nbsp;:&nbsp;</span>
                        <input name="cfdycs" class='is_click' value="" style="color: gray;"
                               onclick="clicklcsj($(this))"/>
                        <input class="cflcsjid" type="hidden" name="cflcsjid" value="" style="color: gray;"/>
                    </div>
                </div>
                <div style="width: 20%; margin-left: 90px; float: left">已分车学员</div>
                <div class="div_zilei" style="margin-left: 90px; float: left">
                    <div style="width: 78%;text-align: right;">
                        <img src="<%=path%>/image/insert2323.jpg" class="addTable">
                        <span style="padding-right: 20px;color:#57a0ff;font-weight:700;font-size: 14px" class="addTable">添加</span>
                        <img src="<%=path%>/image/delete212.png" class="deleteTable">
                        <span class="deleteTable" style="color:#57a0ff;font-weight:700;font-size: 14px" class="deleteTable">删除</span>
                    </div>
                </div>
                <div style="overflow:auto;min-height: 390px;max-height: 390px;width: 88%;margin-left: 90px;">
                    <table id="tablejl" width="200%" style=" min-height:50px;border-spacing:0;white-space:nowrap;">
                        <tr class="tr">
                            <td width="40px" align="right" style="padding-left: 5px"></td>
                            <td width="30px">序号</td>
                            <td align="center">教练组编码</td>
                            <td align="center">教练组</td>
                            <td align="center">是否组长</td>
                            <td align="center">教练</td>
                            <td align="center">教练手机</td>
                            <td align="center">车型</td>
                            <td align="center">车牌号</td>
                            <td align="center">学员</td>
                            <td align="center">学员编码</td>
                            <td align="center">身份证号码</td>
                            <td align="center">是否vip</td>
                            <td align="center">学员状态</td>
                            <td align="center">补/初</td>
                            <td align="center">科目二合格时间</td>
                            <td align="center">科目三考试次数</td>
                            <td align="center">上次不及格时间</td>
                            <td align="center">性别</td>
                            <td align="center">手机</td>
                            <td align="center">电话</td>
                            <td align="center">申领类型</td>
                            <td align="center">本地/异地</td>
                            <td align="center">培训类型</td>
                            <td align="center">推荐人</td>
                            <td align="center">班级</td>
                            <td align="center">应收金额</td>
                            <td align="center">已收</td>
                            <td align="center">优惠</td>
                            <td align="center">欠费</td>
                            <td align="center">备注</td>
                        </tr>
                        <tr>
                            <td width='20px' align='center'><input class='check2' type="checkbox" name="check2"
                                                                   style="width:15px"></td>
                            <td><input type="text" class="fseq" name="fseq" value="1" readonly="readonly"></td>
                            <td align='center'><input class='jlznamebm' style='width: 90px;'
                                                      type='text' name='jlznamebm' value='' readonly="readonly"/>
                            </td>
                            <td name='notcheck' align='center'><input class="is_click_ne" style='width: 90px;'
                                                                      type='text'
                                                                      name='jlzname'
                                                                      value=''
                                                                      onclick='clickJlzxx($(this))'/>
                                <input type="hidden" name="cfjlgroupid"/><%--教练组id--%>
                            </td>
                            <td name='notcheck' align='center'><input style='width: 25px;' type='checkbox'
                                                                      class="cfduizhang2"
                                                                      name='cfduizhang2' value="0"/>
                                <input type="hidden" name="cfduizhang" class="cfduizhang">
                            </td>
                            <td name='notcheck' align='center'><input class="is_click" style='width: 70px;' type='text'
                                                                      name='jlname'
                                                                      value=''
                                                                      onclick='clickJlname($(this))'/>
                                <input type="hidden" name="cfcoachid"/>
                            </td>
                            <td align='center'><input style='width: 90px;' type='text'
                                                      name='cfcoachphone' value='' readonly="readonly"/></td>
                            <td align='center'><input style='width: 90px;' type='text'
                                                      name='cfcarcx' value='' readonly="readonly"/>
                            </td>
                            <td align='center'><input style='width: 90px;' type='text'
                                                      name='cfcarnumber' value='' readonly="readonly"/></td>
                            <td name='notcheck' align='center'><input class="is_click" style='width: 90px;' type='text'
                                                                      name='xyname'
                                                                      value=''
                                                                      onclick='clickName($(this))'/><input type="hidden"
                                                                                                           class="cfstudentid"
                                                                                                           name="cfstudentid"/><%--学员id--%>
                            </td>
                            <td align='center'><input style='width: 120px;' type='text'
                                                      name='cfstudentno' value='' readonly="readonly"/></td>
                            <td align='center'><input style='width: 150px;' type='text'
                                                      name='cfidcardno' value='' readonly="readonly"/></td>
                            <td name='notcheck' align='center'><input style='width: 90px;' type='checkbox'
                                                                      class="cfstuvip2"
                                                                      name='cfstuvip2' value='0'/>
                                <input type="hidden" name="cfstuvip" class="cfstuvip"></td>
                            <td align='center'><input style='width: 170px;' type='text' readonly="readonly"
                                                      name='cfstubillstate' value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' readonly="readonly"
                                                      name='cffristexam' value=''/></td>
                            <td align='center'><input style='width: 140px;' type='text' readonly="readonly"
                                                      name='cfkmesgsj' value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' name='cfkmskscs'
                                                      readonly="readonly"
                                                      value=''/></td>
                            <td align='center'><input style='width: 140px;' type='text' readonly="readonly"
                                                      name='cfkmsbjgsj' value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' name='cfsex' readonly="readonly"
                                                      value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' readonly="readonly"
                                                      name='cfphone' value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' readonly="readonly"
                                                      name='cfmobile' value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' readonly="readonly"
                                                      name='cfsqzjcx' value=''/>
                            </td>
                            <td align='center'><input style='width: 90px;' type='text' name='cfbdyd' readonly="readonly"
                                                      value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' name='cfpxlx' readonly="readonly"
                                                      value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' name='cftjr' readonly="readonly"
                                                      value=''/></td>
                            <td align='center'><input style='width: 180px;' type='text' readonly="readonly"
                                                      name='cfclazz' value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' readonly="readonly"
                                                      name='cfyishou' value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' name='cfysje' readonly="readonly"
                                                      value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' readonly="readonly"
                                                      name='cfyouhui' value=''/></td>
                            <td align='center'><input style='width: 90px;' type='text' readonly="readonly"
                                                      name='cfqianfei' value=''/></td>
                            <td name='notcheck' align='center'><input style='width: 190px;' type='text' name='cfremark'
                                                                      value=''/></td>
                            <td align='center'><input type='hidden'
                                                      name='cfbillstustateid' value=''/></td>
                        </tr>
                    </table>
                </div>

                <div style="line-height:31px; margin-top: 80px; height: 31px; ">
                    <div class="botton">
                        <span class="gn_name">审核人&nbsp;:&nbsp;</span>
                        <input id="shename" disabled='disabled' type="text" name="ffivouchered"
                               value="">
                    </div>
                    <div class="botton">
                        <span class="gn_name">创建人&nbsp;:&nbsp;</span>
                        <input id="createname" disabled='disabled' type="text" name="createName"
                               value="${createName}">
                    </div>
                    <div class="botton">
                        <span class="gn_name">创建时间&nbsp;:&nbsp;</span>
                        <input id="updatetime" disabled='disabled' type="text" name="fcreatetime"
                               value="${recordin.fcreatetime}">
                    </div>
                </div>

                <div class="div_tj" style="margin-bottom: 200px;margin-left: 140px;">
                    <div>
                        <input onclick="chcek()" class="input_submit bc" value="" type="button" style="margin-top: 0px;margin-right: 30px;">
                    </div>
                    <div>
                        <input type="button" class="input_back fh" value="" onclick="back()" style="margin-top: 0px;"/>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<script type="text/javascript" src="<%=path%>/HoganJS/handlebars-v4.0.11.js"></script>
<script type="text/javascript">

    //选中的删除
    $(".deleteTable").click(function () {
        var tr_len = $("#tablejl tr").length;
        var s = '';
        $('input:checkbox[name=check2]').each(function (i) {

            if ($(this).is('.check2:checked')) {

                $(this).parent().parent().remove();
                s = '1';
                reorder()
            }
        })

        //判断是否选中
        if (s == null || s == '') {
            alert("请选择一条数据删除");
            return false;
        }
    })

    //返回
    function back() {
        parent.closeSelectCard()
        //location = '<%=path%>/DrivingSys/querySharecarthreereg/look.action?state=first';
    }


    $('.addTable').click(function () {
        fseq = CalculateMaxNum('tablejl')
        var htmlperson = "<tr>" +
            "<td width='20px' align='center'><input class='check2' type='checkbox' name='check2' style='width:15px'></td>" +
            " <td><input type='text' class='fseq' name='fseq' value='" + fseq + "' readonly='readonly'></td>" +
            "<td align='center'><input class='jlznamebm' style='width: 90px;' type='text' readonly='readonly' name='jlznamebm' value=''/>" +
            "</td><td name='notcheck' align='center'><input style='width: 90px;' class='is_click_ne' type='text' name='jlzname' value='' onclick='clickJlzxx($(this))' /> <input type='hidden'' name='cfjlgroupid'/></td>" +
            "<td align='center'><input style='width: 25px;' type='checkbox' class='cfduizhang2' readonly='readonly' name='cfduizhang2' value='0'/><input type='hidden' name='cfduizhang' class='cfduizhang'> </td>" +
            "<td name='notcheck' align='center'><input style='width: 70px;' type='text' name='jlname' class='is_click' value='' onclick='clickJlname($(this))' /> <input type='hidden' name='cfcoachid'/>" +
            "</td><td align='center'><input style='width: 90px;' type='text' name='cfcoachphone' readonly='readonly' value=''/></td> " +
            "<td align='center'><input style='width: 90px;' type='text' name='cfcarcx' value='' readonly='readonly' />" +
            "</td><td align='center'><input style='width: 90px;' type='text' name='cfcarnumber' readonly='readonly' value=''/></td>" +
            "<td name='notcheck' align='center'><input style='width: 90px;' type='text' name='xyname' value='' class='is_click' onclick='clickName($(this))'/> <input type='hidden' class='cfstudentid' name='cfstudentid'/>" +
            "</td><td align='center'><input style='width: 120px;' type='text' name='cfstudentno' readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 150px;' type='text' name='cfidcardno' readonly='readonly' value=''/></td>" +
            "<td name='notcheck' name='notcheck' align='center'><input style='width: 90px;' type='checkbox'  class='cfstuvip2' name='cfstuvip2' value='0'/> <input type='hidden' name='cfstuvip' class='cfstuvip'></td>" +
            "<td align='center'><input style='width: 170px;' type='text' name='cfstubillstate' readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cffristexam' readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 140px;' type='text' name='cfkmesgsj'readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfkmskscs' readonly='readonly' value=''/></td> " +
            "<td align='center'><input style='width: 140px;' type='text' name='cfkmsbjgsj' readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfsex' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfphone' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfmobile' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfsqzjcx' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfbdyd' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfpxlx' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cftjr' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 180px;' type='text' name='cfclazz' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfyishou' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfysje' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfyouhui' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfqianfei' value='' readonly='readonly' /></td>" +
            "<td name='notcheck' align='center'><input style='width: 190px;' type='text' name='cfremark'  value=''/></td> " +
            "<td align='center'><input style='display: none;' type='text' name='cfbillstustateid' value=''/></td></tr>";
        $("#tablejl").append(htmlperson)
    })

    function addStu() {
        fseq = CalculateMaxNum('tablejl')
        var htmlperson = "<tr>" +
            "<td width='20px' align='center'><input class='check2' type='checkbox' name='check2' style='width:15px'></td>" +
            " <td><input type='text' class='fseq' name='fseq' value='" + fseq + "' readonly='readonly'></td>" +
            "<td align='center'><input class='jlznamebm' style='width: 90px;' type='text' readonly='readonly' name='jlznamebm' value=''/>" +
            "</td><td name='notcheck' align='center'><input style='width: 90px;' class='is_click_ne' type='text' name='jlzname' value='' onclick='clickJlzxx($(this))' /> <input type='hidden'' name='cfjlgroupid'/></td>" +
            "<td align='center'><input style='width: 25px;' type='checkbox' class='cfduizhang2' readonly='readonly' name='cfduizhang2' value='0'/><input type='hidden' name='cfduizhang' class='cfduizhang'> </td>" +
            "<td name='notcheck' align='center'><input style='width: 70px;' type='text' name='jlname' class='is_click' value='' onclick='clickJlname($(this))' /> <input type='hidden' name='cfcoachid'/>" +
            "</td><td align='center'><input style='width: 90px;' type='text' name='cfcoachphone' readonly='readonly' value=''/></td> " +
            "<td align='center'><input style='width: 90px;' type='text' name='cfcarcx' value='' readonly='readonly' />" +
            "</td><td align='center'><input style='width: 90px;' type='text' name='cfcarnumber' readonly='readonly' value=''/></td>" +
            "<td name='notcheck' align='center'><input style='width: 90px;' type='text' name='xyname' value='' class='is_click' onclick='clickName($(this))'/> <input type='hidden' class='cfstudentid' name='cfstudentid'/>" +
            "</td><td align='center'><input style='width: 120px;' type='text' name='cfstudentno' readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 150px;' type='text' name='cfidcardno' readonly='readonly' value=''/></td>" +
            "<td name='notcheck' name='notcheck' align='center'><input style='width: 90px;' type='checkbox'  class='cfstuvip2' name='cfstuvip2' value='0'/> <input type='hidden' name='cfstuvip' class='cfstuvip'></td>" +
            "<td align='center'><input style='width: 170px;' type='text' name='cfstubillstate' readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cffristexam' readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 140px;' type='text' name='cfkmesgsj'readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfkmskscs' readonly='readonly' value=''/></td> " +
            "<td align='center'><input style='width: 140px;' type='text' name='cfkmsbjgsj' readonly='readonly' value=''/></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfsex' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfphone' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfmobile' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfsqzjcx' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfbdyd' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfpxlx' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cftjr' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 180px;' type='text' name='cfclazz' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfyishou' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfysje' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfyouhui' value='' readonly='readonly' /></td>" +
            "<td align='center'><input style='width: 90px;' type='text' name='cfqianfei' value='' readonly='readonly' /></td>" +
            "<td name='notcheck' align='center'><input style='width: 190px;' type='text' name='cfremark'  value=''/></td> " +
            "<td align='center'><input style='display: none;' type='text' name='cfbillstustateid' value=''/></td></tr>";
        $("#tablejl").append(htmlperson)
    }


    //设置全选功选
    $('.check').click(function () {
        if ($(this).attr("checked")) {
            $(".check2:checkbox").prop("checked", true)
        } else {
            $('.check2:checkbox').removeAttr('checked')
        }
    })
    //由于和input:checkbox冲突，在选择一次
    $("#tablejl tr td .check2:checkbox").live('click', function () {
        if ($(this).is('.check2:checked')) {
            $(this).removeAttr("checked");
        } else {
            $(this).attr("checked", ".check2:checked")
        }
    })
    //单击选中
    $("#tablejl tr td").live('click', function () {
        if ($(this).parent().find(".check2:checkbox").is(':checked')) {
            $(this).parent().find(".check2:checkbox").removeAttr("checked");
        } else {
            $(this).parent().find(".check2:checkbox").attr("checked", ":checked")
        }
    })


    //改变复选框的值
    function chcek() {

        $(".cfduizhang2").each(function () {
            if ($(this).is(':checked')) {
                $(this).next().val(1);
            } else {
                $(this).next().val(0);
            }
        });
        $(".cfstuvip2").each(function () {
            if ($(this).is(':checked')) {
                $(this).next().val(1);
            } else {
                $(this).next().val(0);
            }
        });
        if ($('#update_shar').find("tr").length == 1) {
            alert('请至少选择一条数据！')
            return false;
        }
        $('#update_shar').submit()

    }

    /* 关闭弹出框    */
    $('.btn').click(function () {
        $('#modal-overlay').css('visibility', 'hidden')
        $('.modal-data').css('visibility', 'hidden')
        $('.modal-data1').css('visibility', 'hidden')
        $('.modal-data2').css('visibility', 'hidden')
        $('.modal-data3').css('visibility', 'hidden')
        $('.data-checkbox:checkbox').removeAttr('checked');
        $('.data1-checkbox:checkbox').removeAttr('checked');
        $('.data2-checkbox:checkbox').removeAttr('checked');
        $('.data3-checkbox:checkbox').removeAttr('checked');
        $('.page').hide();
    })

    //弹出练车时间的信息框
    function clicklcsj(e) {
        $('#modal-overlay').css('visibility', 'visible')
        $('.modal-data3').css('visibility', 'visible')
        $('.data3-checkbox:checkbox').removeAttr('checked');
        $('.page').show();
        _this = e;
    }

    //弹出模式框教练组信息
    function clickJlzxx(e) {
        $('#modal-overlay').css('visibility', 'visible')
        $('.modal-data2').css('visibility', 'visible')
        $('.data2-checkbox:checkbox').removeAttr('checked');
        $('.page').show();
        _this = e.parent().parent();
    }

    //弹出模式框教练信息
    function clickJlname(e) {
        $('#modal-overlay').css('visibility', 'visible')
        $('.modal-data1').css('visibility', 'visible')
        $('.data1-checkbox:checkbox').removeAttr('checked');
        $('.page').show();
        _this = e.parent().parent();
    }

    //弹出模式框学生信息
    function clickName(e) {
        $('#modal-overlay').css('visibility', 'visible')
        $('.modal-data').css('visibility', 'visible')
        $('.data-checkbox:checkbox').removeAttr('checked');
        $('.page').show();
        _this = e.parent().parent();

        cflcsjid = $(".cflcsjid").val();
        $.ajax({
            url: '<%=path2%>/DrivingSys/getPageEnrol',
            type: "post",
            data: {
                'pindex': '0',
                'name': myname,
                'cfsjhm': cflxdh,
                'beginTime': beginTime.val(),
                'endTime': endTime.val(),
                'state': 3,
                'type': 'fc',
                'cflcsjid': cflcsjid
            },
            dataType: "json",
            success: function (res) {
                $('#studebntList').html(myTemplate(res));
                $('#totalPage').val(res.pb);
            },
            error: function () {
                alert('Error');
            }
        });
    }


    //把选中教练组名称和编码回填
    $('#subtn2').click(function () {
        var spCodesTemp = "";
        $('.coacegroup input:checkbox[name=coachesfid]:checked').each(function (i) {
            spCodesTemp = $(this).val();
        });
        if (spCodesTemp == "") {
            alert('请选择练教练组信息！');
            return false;
        }

        $.ajax({
            url: '<%=path%>/DrivingSys/selectCoaceGroupByFidAsPage',
            type: "post",
            data: {'id': spCodesTemp},
            dataType: "json",
            success: function (res) {
                _this.children().children('input[name=jlznamebm]').val(res[0].fnumber);
                _this.children().children('input[name=jlzname]').val(res[0].fnameL2);
                //存入教练组id
                _this.children().children('input[name=cfjlgroupid]').val(res[0].fid);
                $('#modal-overlay').css('visibility', 'hidden')
                $('.modal-data2').css('visibility', 'hidden')
            },
            error: function () {
                alert('Error');
            }
        });

    });

    //把选中的信息名称填充到输入框中
    $('#subtn1').click(function () {
        var spCodesTemp = "";
        $('input:checkbox[name=personfid]:checked').each(function (i) {
            spCodesTemp = $(this).val();
        });
        if (spCodesTemp == "") {
            alert('请选择练教练信息！');
            return false;
        }
        $.ajax({
            url: '<%=path%>/DrivingSys/selectPersonByFidAsPage',
            type: "post",
            data: {'id': spCodesTemp},
            dataType: "json",
            success: function (res) {
                _this.children().children('input[name=jlznamebm]').val(res[0].fnumber);
                _this.children().children('input[name=jlzname]').val(res[0].jlzname);
                _this.children().children('input[name=cfcoachid]').val(res[0].fid);
                /*if (res[0].cfisvip == 0)
                 _this.children().children('input[name=cfduizhang]')*/
                _this.children().children('input[name=jlname]').val(res[0].jlname);
                _this.children().children('input[name=cfcoachphone]').val(res[0].cfphone);
                _this.children().children('input[name=cfcarcx]').val(res[0].cfcarcx);
                _this.children().children('input[name=cfcarnumber]').val(res[0].cfcarnumber);
                _this.children().children('input[name=cfjlgroupid]').val(res[0].cfcoachid);//教练组id

                if (res[0].jlznamebm == null || res[0].jlzname == null) {
                    alert("没有找到" + res[0].jlname + "的组!");
                }

                $('#modal-overlay').css('visibility', 'hidden')
                $('.modal-data1').css('visibility', 'hidden')
            },
            error: function () {
                alert('Error');
            }
        });

    });

    //把选中的学生信息名称填充到输入框中
    $('.subtn').click(function () {
        var spCodesTemp = "";
        $('input:checkbox[name=student]:checked').each(function (i) {
            spCodesTemp = $(this).val();
        });

        var eachcount = 0;
        if (spCodesTemp == "") {
            alert('请选择练学生信息！');
            return false;
        }

        $.ajax({
            url: '<%=path%>/DrivingSys/selStudentsByFid',
            type: "post",
            data: {'id': spCodesTemp},
            dataType: "json",
            success: function (res) {
                res = res.studentsNameList[0];

                $('.cfstudentid').each(function () {


                    if ($(this).val() == res.fid) {
                        alert('学员' + res.fnameL2 + '信息重复！');
                        return false;
                    }

                    eachcount++

                    if (eachcount >= $(".cfstudentid").length) {
                        addData(res)
                        //查询是否有同车学员
                        $.ajax({
                            url: '<%=path%>/DrivingSys/selStudentsByFidAsCar',
                            type: "post",
                            data: {
                                'id': spCodesTemp,
                                'cflcsjid': cflcsjid = $(".cflcsjid").val(),
                                'kemu': '3'
                            },
                            dataType: "json",
                            success: function (res1) {
                                if (res1.studentsNameList.length > 0) {

                                    $.messager.confirm('提示', '是否把同车学员添加到列表中?', function (r) {
                                        if (r)
                                            for (var s = 0; s < res1.studentsNameList.length; s++) {
                                                addStu();
                                                addData2(res1.studentsNameList[s]);
                                            }
                                    });
                                }
                            }
                        })
                    }

                })
            },
            error: function () {
                alert('Error');
            }
        });

    });

    //添加学生
    function addData(res) {
        _this.children().children('input[name=cfstudentid]').val(res.fid);
        _this.children().children('input[name=xyname]').val(res.fnameL2);
        _this.children().children('input[name=cfstudentno]').val(res.fnumber);
        _this.children().children('input[name=cfidcardno]').val(res.cfidcardno);
        if (res.cfvip == 1) {
            _this.children().children('input[name=cfstuvip2]').attr("checked", true);
        }
        if (res.cfstudentstate == 2) {
            _this.children().children('input[name=cfstubillstate]').val('科目一通过');
        }
        if (res.cfstudentstate == 4) {
            _this.children().children('input[name=cfstubillstate]').val('科目二通过,科目三未开始');
        }
        if (res.cfstudentstate == 5) {
            _this.children().children('input[name=cfstubillstate]').val('科目二未通过,科目三未开始');
        }
        if (res.cfstudentstate == 7) {
            _this.children().children('input[name=cfstubillstate]').val('科目三通过,科目二通过');
        }
        if (res.cfstudentstate == 8) {
            _this.children().children('input[name=cfstubillstate]').val('科目三未通过,科目二通过');
        }
        if (res.cfstudentstate == 20) {
            _this.children().children('input[name=cfstubillstate]').val('科目二未通过,科目三未通过');
        }
        if (res.cfstudentstate == 21) {
            _this.children().children('input[name=cfstubillstate]').val('科目三未通过，科目二未开始');
        }
        //学员状态
        _this.children().children('input[name=cfbillstustateid]').val(res.cfstudentstate);
        if (res.cfkmsbjgsj == null) {
            _this.children().children('input[name=cffristexam]').val('初考');
        } else {
            _this.children().children('input[name=cffristexam]').val('补考');
        }
        _this.children().children('input[name=cfkmesgsj]').val(res.cfkmehgrq);
        _this.children().children('input[name=cfkmskscs]').val(res.cfkmskss);
        _this.children().children('input[name=cfkmsbjgsj]').val(res.cfkmsbjgsj);
        if (res.cfsex == 1) {
            _this.children().children('input[name=cfsex]').val('男');
        }
        if (res.cfsex == 2) {
            _this.children().children('input[name=cfsex]').val('女');
        }
        _this.children().children('input[name=cfmobile]').val(res.cfsjhm);
        _this.children().children('input[name=cfphone]').val(res.cflxdh);
        _this.children().children('input[name=cfsqzjcx]').val(res.cfslzjcxdh);
        if (res.cflocal == 1) {
            _this.children().children('input[name=cfbdyd]').val('本地');
        }
        if (res.cflocal == 2) {
            _this.children().children('input[name=cfbdyd]').val('异地');
        }
        _this.children().children('input[name=cfpxlx]').val(res.cftrainTypeNAME);
        _this.children().children('input[name=cftjr]').val(res.cftjrName);
        _this.children().children('input[name=cfclazz]').val(res.cfclazzName);
        _this.children().children('input[name=cfyishou]').val(res.cfamount);
        _this.children().children('input[name=cfysje]').val(res.cfreceived);
        _this.children().children('input[name=cfyouhui]').val(res.cffavorable);
        _this.children().children('input[name=cfqianfei]').val(res.cfarrearage);
        _this.children().children('input[name=cfremark]').val(res.cfdesc);

        $('#modal-overlay').css('visibility', 'hidden')
        $('.modal-data').css('visibility', 'hidden')
    }

    //添加学生
    function addData2(res) {
        _this = $("#tablejl").find("tr:last");
        _this.children().children('input[name=cfstudentid]').val(res.fid);
        _this.children().children('input[name=xyname]').val(res.fnameL2);
        _this.children().children('input[name=cfstudentno]').val(res.fnumber);
        _this.children().children('input[name=cfidcardno]').val(res.cfidcardno);
        if (res.cfvip == 1) {
            _this.children().children('input[name=cfstuvip2]').attr("checked", true);
        }
        if (res.cfstudentstate == 2) {
            _this.children().children('input[name=cfstubillstate]').val('科目一通过');
        }
        if (res.cfstudentstate == 4) {
            _this.children().children('input[name=cfstubillstate]').val('科目二通过,科目三未开始');
        }
        if (res.cfstudentstate == 5) {
            _this.children().children('input[name=cfstubillstate]').val('科目二未通过,科目三未开始');
        }
        if (res.cfstudentstate == 7) {
            _this.children().children('input[name=cfstubillstate]').val('科目三通过,科目二通过');
        }
        if (res.cfstudentstate == 8) {
            _this.children().children('input[name=cfstubillstate]').val('科目三未通过,科目二通过');
        }
        if (res.cfstudentstate == 20) {
            _this.children().children('input[name=cfstubillstate]').val('科目二未通过,科目三未通过');
        }
        if (res.cfstudentstate == 21) {
            _this.children().children('input[name=cfstubillstate]').val('科目三未通过，科目二未开始');
        }
        //学员状态
        _this.children().children('input[name=cfbillstustateid]').val(res.cfstudentstate);
        if (res.cfkmsbjgsj == null) {
            _this.children().children('input[name=cffristexam]').val('初考');
        } else {
            _this.children().children('input[name=cffristexam]').val('补考');
        }
        _this.children().children('input[name=cfkmesgsj]').val(res.cfkmehgrq);
        _this.children().children('input[name=cfkmskscs]').val(res.cfkmskss);
        _this.children().children('input[name=cfkmsbjgsj]').val(res.cfkmsbjgsj);
        if (res.cfsex == 1) {
            _this.children().children('input[name=cfsex]').val('男');
        }
        if (res.cfsex == 2) {
            _this.children().children('input[name=cfsex]').val('女');
        }
        _this.children().children('input[name=cfmobile]').val(res.cfsjhm);
        _this.children().children('input[name=cfphone]').val(res.cflxdh);
        _this.children().children('input[name=cfsqzjcx]').val(res.cfslzjcxdh);
        if (res.cflocal == 1) {
            _this.children().children('input[name=cfbdyd]').val('本地');
        }
        if (res.cflocal == 2) {
            _this.children().children('input[name=cfbdyd]').val('异地');
        }
        _this.children().children('input[name=cfpxlx]').val(res.cftrainTypeNAME);
        _this.children().children('input[name=cftjr]').val(res.cftjrName);
        _this.children().children('input[name=cfclazz]').val(res.cfclazzName);
        _this.children().children('input[name=cfyishou]').val(res.cfamount);
        _this.children().children('input[name=cfysje]').val(res.cfreceived);
        _this.children().children('input[name=cfyouhui]').val(res.cffavorable);
        _this.children().children('input[name=cfqianfei]').val(res.cfarrearage);
        _this.children().children('input[name=cfremark]').val(res.cfdesc);

        $('#modal-overlay').css('visibility', 'hidden')
        $('.modal-data').css('visibility', 'hidden')
    }


</script>
<%@ include file="/WEB-INF/JSP/ajax.jsp" %>
</html>